package com.scnu.domain.activity.service.trial.thread;

import com.scnu.domain.activity.adapter.repository.IActivityRepository;
import com.scnu.domain.activity.model.valobj.GroupBuyActivityDiscountVO;
import com.scnu.domain.activity.model.valobj.SCSkuActivityVO;

import javax.annotation.Resource;
import java.util.concurrent.Callable;

public class queryGroupBuyActivityDiscountVOThreadTask implements Callable<GroupBuyActivityDiscountVO> {

    private final String source;
    private final String channel;
    private final IActivityRepository repository;
    private final String goodsId;

    public queryGroupBuyActivityDiscountVOThreadTask(String channel, String source, IActivityRepository repository, String goodsId) {
        this.channel = channel;
        this.source = source;
        this.repository = repository;
        this.goodsId = goodsId;
    }

    @Override
    public GroupBuyActivityDiscountVO call() throws Exception {
        SCSkuActivityVO scSkuActivityVO = repository.querySCSkuActivityBySCGoodsId(source,channel,goodsId);
        if(scSkuActivityVO==null){
            return null;
        }
        return repository.queryGroupBuyActivityDiscountVO(scSkuActivityVO.getActivityId());
    }
}
